<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Cache-Control" content="no-siteapp" />
         <link href="/TP/Public/assets/css/bootstrap.min.css" rel="stylesheet" />
        <link rel="stylesheet" href="/TP/Public/css/style.css"/>       
        <link href="/TP/Public/assets/css/codemirror.css" rel="stylesheet">
        <link rel="stylesheet" href="/TP/Public/assets/css/ace.min.css" />
        <link rel="stylesheet" href="/TP/Public/font/css/font-awesome.min.css" />
        <!--[if lte IE 8]>
		  <link rel="stylesheet" href="assets/css/ace-ie.min.css" />
		<![endif]-->
		<script src="/TP/Public/js/jquery-2.1.3.min.js"></script>
        <script src="/TP/Public/assets/js/bootstrap.min.js"></script>
       <!--  <script type="text/javascript" src="/TP/Public/Widget/Validform/5.3.2/Validform.min.js"></script>
		<script src="/TP/Public/assets/js/typeahead-bs2.min.js"></script>           	
		<script src="/TP/Public/assets/js/jquery.dataTables.min.js"></script>
		<script src="/TP/Public/assets/js/jquery.dataTables.bootstrap.js"></script>
        <script src="/TP/Public/assets/layer/layer.js" type="text/javascript" ></script>          
		<script src="/TP/Public/js/lrtk.js" type="text/javascript" ></script>
         <script src="/TP/Public/assets/layer/layer.js" type="text/javascript"></script>	
        <script src="/TP/Public/assets/laydate/laydate.js" type="text/javascript"></script> -->
<title>管理员</title>
</head>

<body>
<div class="page-content clearfix">
  <div class="administrator">
   <!-- 搜索栏？ -->
       <!-- <form class="form-inline">
        <div class="form-group">
          <input type="text" class="form-control" id="exampleInputName2" placeholder="请输入用户名">
        </div>
        <button type="submit" class="btn btn-default">搜索</button>
             </form> -->
      <div class="table_menu_list"  id="testIframe">
           <table class="table table-striped table-bordered table-hover" id="sample_table">
		<thead>
		 <tr>
				<!-- <th width="25px"><label><input type="checkbox" class="ace"><span class="lbl"></span></label></th> -->
				<th width="80px">编号</th>
				<th width="250px">登录名</th>
				<th width="100px">手机</th>
				<th width="100px">邮箱</th>
                <th width="100px">角色</th>				
				<th width="180px">加入时间</th>
				<th width="70px">状态</th>                
				<th width="200px">操作</th>
			</tr>
		</thead>
	<tbody>
    <?php if(is_array($list)): foreach($list as $key=>$val): ?><tr id="admin_tr<?php echo ($val["id"]); ?>">
      <td><?php echo ($val["id"]); ?></td>
      <td><?php echo ($val["name"]); ?></td>
      <td><?php echo ($val["phone"]); ?></td>
      <td><?php echo ($val["email"]); ?></td>
      <td ><?php echo ($val["status"]); ?></td>
      <td><?php echo ($val["addtime"]); ?></td>
      <td class="td-status"><span class="label label-success radius" id="state_s<?php echo ($val["id"]); ?>"><?php echo ($val["state"]); ?></span></td>
      <td class="td-manage">
        <a onclick="admin_start(<?php echo ($val["id"]); ?>)"  href="javascript:;" id="state_<?php echo ($val["id"]); ?>" class="btn btn-xs btn-success">修改状态</a>
       <a  href="javascript:;"  onclick="admin_del(<?php echo ($val["id"]); ?>)" id="admin_<?php echo ($val["id"]); ?>" class="btn btn-xs btn-warning" >删除</a>
       </td>
     </tr><?php endforeach; endif; ?>
    </tbody>
    </table>
        <div id="btnBox" align="right"><?php echo ($show); ?></div>
      </div>
     </div>
  </div>
</div>

</body>
</html>
<script type="text/javascript">
    $('#btnBox').children().children().unwrap().wrap('<li></li>').parent().wrapAll('<ul class="pagination"></ul>');
    // 给当前页码高亮显示
    $('#btnBox span').parent().addClass('active');
    // var id = <?php echo (session('admin_id')); ?>;
    // alert(id)
    //设置超管不能修改自己状态
    $('#state_3').removeAttr('onclick');
    $('#admin_3').removeAttr('onclick');
    //获取当前用户权限值
    var status = <?php echo (session('admin_status')); ?>;
    // window.load();
    //点击修改时
    function admin_start(id){
        if(status == 2){
            $.get("<?php echo U('Admin/Admin/up_admin');?>",{'id':id},function(data){
                if(data == '修改成功'){
                    var state_s = '#state_s'+id;
                    var state = '#state_'+id;
                    var comment = $(state).text();
                    // alert(comment);
                    if(comment == '禁用' || comment == '修改状态'){
                        $(state).text('启用');
                        $(state_s).text('禁用');
                    }else{
                        $(state).text('禁用');
                        $(state_s).text('启用');
                    }
                }else{
                    alert(data);
                }
            });
        }else{
            alert('无权限');
        }
    }

    function admin_del(id){
        if(status == 2){
          if(confirm('是否删除') == true){
              $.get("<?php echo U('Admin/Admin/del_admin');?>",{'id':id},function(data){
                if(data == '删除成功'){
                    var state_s = '#admin_tr'+id;
                    $(state_s).remove();
                }else{
                    alert(data);
                }
            });
          }
            
        }else{
            alert('无权限');
        }
    }
</script>